import { createStore } from 'vuex'
import { getMusicLyrics } from '@/request/api/item'
import { getPhoneLogin } from '@/request/api/home'
export default createStore({
  state: {
    playlist: [{
      //播放列表默认值
      al: {
        id: 133720183,
        name: "偏偏喜欢你",
        pic: 109951166450681440,
        picUrl: "http://p4.music.126.net/fpfFspuQW-2J8meRr1q-Aw==/109951166450681435.jpg",
        pic_str: "109951166450681435"
      },
      id: 1880855946,
      name: "偏偏喜欢你",
    }],
    playlistIndex: 0,//默认的下标为零
    isbtnShow:true,//播放暂停按钮
    detailShow:false,//详情页展示
    lyricList:{},//歌词
    currentTime:0,//当前时间
    duration:0,//歌曲总时长
    isLogin:false,//判断是否登录
    isFooterMusic:true,//是否显示底部组件
  },
  getters: {
  },
  mutations: {
    updateIsbtnShow(state,value){
      state.isbtnShow=value
    },
    updatePlayList(state,value){
      state.playlist=value
    },
    pushPlayList(state,value){
      state.playlist.push(value)
    },
    updatePlayListIndex(state,value){
      state.playlistIndex=value
    },
    updateDetailShow(){
      this.state.detailShow = !this.state.detailShow
    },
    updateLyricList(state,value){
      state.lyricList = value
    },
    updateCurrentTime(state,value){
      state.currentTime = value
    },
    updateDuration(state,value){
      state.duration = value
    },
    updateIsLogin(state,value){
      state.isLogin = value
    }
  },
  actions: {
    async getLyric(context,value){
      let res = await getMusicLyrics(value)
      console.log(res);
      context.commit("updateLyricList",res.data.lrc)
    },
    async getLogin(context,value){
      let res = await getPhoneLogin(value)
      // console.log(res);
      return res
    }

  },
  modules: {
  }
})
